
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>滑动验证 | home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="滑动验证
1.在template12345&amp;lt;drag-verify :width&amp;#x3D;&amp;quot;width&amp;quot;             :height&amp;#x3D;&amp;quot;height&amp;quot;             :text&amp;#x3D;&amp;quot;text&amp;quot;             ref&amp;#x3D;&amp;quot;Verify&amp;quot;&amp;gt;&amp;lt;&amp;#x2F;drag-verify&amp;gt;

2.在script设置属性 (npm install vue-drag-verify –save)123456789101112131415161718192021222324&amp;#x2F...">
    
        <link rel="icon" href="/favicon.ico">
    
    
        
            <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
        
            <link rel="stylesheet" href="/css/stage.css">
        
            <link rel="stylesheet" href="/css/avatar-bg.css">
        
    
<meta name="generator" content="Hexo 4.2.0"></head>

<body>
<header id="header">
    <div class="menu">
        <i class="fa fa-bars"></i>
    </div>
    <div class="header-main">
        <h1><a href="/">home</a></h1>
    </div>
    <div id="nav">
        <div class="nav-img" id="nav-img"></div>
        <div class="sentences">
            桃花潭水深千尺，不及汪伦送我情。——李白
        </div>
    </div>
</header>

<div id="content-outer">
    <div id="content-inner">
        <div class="clearfix">
    <article id="post">
        <h1>滑动验证</h1>
        <div class="create">
            <span>Created</span>
            
                <time datetime="2020-04-25T06:30:35.000Z">
                    2020-04-25
                </time>
            
            
        </div>
        <h1 id="滑动验证"><a href="#滑动验证" class="headerlink" title="滑动验证"></a>滑动验证</h1><hr>
<h3 id="1-在template"><a href="#1-在template" class="headerlink" title="1.在template"></a>1.在template</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;drag-verify :width&#x3D;&quot;width&quot;</span><br><span class="line">             :height&#x3D;&quot;height&quot;</span><br><span class="line">             :text&#x3D;&quot;text&quot;</span><br><span class="line">             ref&#x3D;&quot;Verify&quot;&gt;</span><br><span class="line">&lt;&#x2F;drag-verify&gt;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="2-在script设置属性-npm-install-vue-drag-verify-–save"><a href="#2-在script设置属性-npm-install-vue-drag-verify-–save" class="headerlink" title="2.在script设置属性 (npm install vue-drag-verify –save)"></a>2.在script设置属性 (npm install vue-drag-verify –save)</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 导包</span><br><span class="line">import dragVerify from &#39;vue-drag-verify&#39;</span><br><span class="line"></span><br><span class="line">export default &#123;</span><br><span class="line">  data () &#123;</span><br><span class="line">    return &#123;</span><br><span class="line">      &#x2F;&#x2F; 在data里面设置滑动的属性</span><br><span class="line">      width: 320,</span><br><span class="line">      height: 42,</span><br><span class="line">      text: &#39;请将滑块拖到最右侧&#39;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;，</span><br><span class="line">  &#x2F;&#x2F; 注册标签</span><br><span class="line">  components: &#123;</span><br><span class="line">    &#39;dragVerify&#39;: dragVerify</span><br><span class="line">  &#125;,</span><br><span class="line">  &#x2F;&#x2F;检验是否拖动</span><br><span class="line">  methods：&#123;</span><br><span class="line">      &#x2F;&#x2F;滑块是否拖动false为未拖动至最右侧反之为true</span><br><span class="line">			if(this.$refs.Verify.isPassing &#x3D;&#x3D; false)&#123;</span><br><span class="line">				this.$Notice(&#39;请拖动滑块&#39;)</span><br><span class="line">			&#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="selenium破解滑块"><a href="#selenium破解滑块" class="headerlink" title="selenium破解滑块"></a>selenium破解滑块</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> selenium <span class="keyword">import</span> webdriver</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver <span class="keyword">import</span> ChromeOptions</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver <span class="keyword">import</span> ActionChains</span><br><span class="line"></span><br><span class="line">option = ChromeOptions()  <span class="comment"># 实例化一个ChromeOptions对象</span></span><br><span class="line">option.add_experimental_option(<span class="string">'excludeSwitches'</span>, [<span class="string">'enable-automation'</span>])  <span class="comment"># 以键值对的形式加入参数</span></span><br><span class="line">browser = webdriver.Chrome(options=option)</span><br><span class="line"><span class="comment">#发起请求</span></span><br><span class="line">browser.get(<span class="string">'http://127.0.0.1:8080/login)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">#定位滑块</span></span><br><span class="line"><span class="string">button = browser.find_element_by_class_name("dv_handler")</span></span><br><span class="line"><span class="string">action = ActionChains(browser)</span></span><br><span class="line"><span class="string">#获取小球长度</span></span><br><span class="line"><span class="string">mybutton = button.size.get('</span>width<span class="string">')</span></span><br><span class="line"><span class="string">#获取滑块轨道总长</span></span><br><span class="line"><span class="string">mytext = browser.find_element_by_class_name('</span>dv_text<span class="string">').size.get('</span>width<span class="string">')</span></span><br><span class="line"><span class="string">#按住拖动</span></span><br><span class="line"><span class="string">action.click_and_hold(button).perform()</span></span><br><span class="line"><span class="string">#拖动位置</span></span><br><span class="line"><span class="string">action.move_by_offset(int(mytext)-int(mybutton),0).perform()</span></span><br></pre></td></tr></table></figure>

        <div>
            <ul class="tags-category-list" itemprop="keywords"><li class="tags-category-list-item"><a class="tags-category-list-link" href="/hexo_blog/tags/python/" rel="tag">python</a></li></ul>
        </div>
        <div class="bottom-line"></div>
        
    <nav id="article-nav">
        
            <a href="/hexo_blog/2020/04/26/Vcode/" id="article-nav-newer" class="article-nav-link-wrap">
        <span class="article-nav-title">
            
                自定义验证码
            
        </span>
                <strong class="article-nav-caption">&gt;</strong>
            </a>
        
        
            <a href="/hexo_blog/2020/04/24/%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E5%9B%BE%E7%89%87%E9%AA%8C%E8%AF%81%E7%A0%81/" id="article-nav-older" class="article-nav-link-wrap">
                <strong class="article-nav-caption">&lt;</strong>
                <span class="article-nav-title">
                    
                        手写验证码
                </span>
                
            </a>
        
    </nav>


        
    </article>
    <div id="toc">
        
            <h2>Table of Contents</h2>
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#滑动验证"><span class="toc-number">1.</span> <span class="toc-text">滑动验证</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-在template"><span class="toc-number">1.0.1.</span> <span class="toc-text">1.在template</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-在script设置属性-npm-install-vue-drag-verify-–save"><span class="toc-number">1.0.2.</span> <span class="toc-text">2.在script设置属性 (npm install vue-drag-verify –save)</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#selenium破解滑块"><span class="toc-number">1.1.</span> <span class="toc-text">selenium破解滑块</span></a></li></ol></li></ol>
        
    </div>
</div>

    </div>
</div>
<footer id="footer">
    <div id="copyright">&copy; Mr.Song  2020</div>
    <div id="theme">
        Powered by <a href="http://hexo.io" target="_blank" rel="noopener">Hexo</a>. Theme by <a href="https://github.com/markyong/hexo-theme-stage" target="_blank" rel="noopener">Stage</a>
    </div>
</footer>
<script src="/lib/js/waterrippleeffect.min.js"></script>
<script src="/js/header-bg.main.js"></script>

    <script src="/lib/js/smooth-scroll.min.js"></script>
    <script src="/js/toc.main.js"></script>

</body>
</html>
